import { IDispose } from "../../../../../com/gengine/core/IDispose";
import { ChatCellData } from "./ChatCellData";
import { ChatType } from "./ChatType";
import { ChatStyle } from "../chatPanel/ChatStyle";
import { ObjectPool } from "../../../../../com/gengine/utils/pools/ObjectPool";
import { ChatCell } from "../chatPanel/ChatCell";
import { Vector } from "../../../../../__AS3__/vec/Vector";
//class ChatItemData
    
    export  class ChatItemData implements IDispose
    {
        

        public init(arg1: string=null, arg2: Vector.<ChatCellData>=null): void
        {
            if (!arg1) 
            {
                arg1 = ChatType.World;
            }
            this._type = arg1;
            this._cellVector = arg2;
            return;
        }

        public get type(): string
        {
            return this._type;
        }

        public set type(arg1: string)
        {
            this._type = arg1;
            return;
        }

        public get cellVector(): Vector.<ChatCellData>
        {
            return this._cellVector;
        }

        public set cellVector(arg1: Vector.<ChatCellData>)
        {
            this._cellVector = arg1;
            return;
        }

        public addCellData(arg1: ChatCellData): void
        {
            this._cellVector.push(arg1);
            return;
        }

        public getAllElements(): Vector.<flash.text.engine.ContentElement>
        {
            var loc2=null;
            var loc3=null;
            var loc5=0;
            var loc6=null;
            var loc1=new Vector.<flash.text.engine.ContentElement>();
            var loc4=new Object /* flash.text.engine.TextElement */("  " + this._type + " ", ChatStyle.getTitleFormat(this._type));
            loc1.push(loc4);
            if (this._cellVector) 
            {
                loc5 = 0;
                while (loc5 < this._cellVector.length) 
                {
                    (loc6 = ObjectPool.getObject(ChatCell)).init(this._cellVector[loc5]);
                    loc1.push(loc6.cellContentElement);
                    ++loc5;
                }
            }
            return loc1;
        }

        public getContentElement(): Vector.<flash.text.engine.ContentElement>
        {
            var loc2=0;
            var loc3=null;
            var loc1=new Vector.<flash.text.engine.ContentElement>();
            if (this._cellVector) 
            {
                loc2 = 0;
                while (loc2 < this._cellVector.length) 
                {
                    loc3 = ObjectPool.getObject(ChatCell);
                    loc3.init(this._cellVector[loc2]);
                    loc1.push(loc3.cellContentElement);
                    ++loc2;
                }
            }
            return loc1;
        }

        public dispose(arg1: Boolean=true): void
        {
            this._type = null;
            this._cellVector = null;
            ObjectPool.disposeObject(this);
            return;
        }

        /* internal */ /* var */_type: string;

        /* internal */ /* var */_cellVector: Vector.<ChatCellData>;
    }
